<?php
/*
Bitsand - a web-based booking system for LRP events
Copyright (C) 2006 - 2008 The Bitsand Project (http://bitsand.googlecode.com/)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

//Initialise $CSS_PREFIX
$CSS_PREFIX = '../';

//Load required inc files
include ($CSS_PREFIX . 'inc/inc_head_db.php');
include ($CSS_PREFIX . 'inc/inc_admin.php');
include ($CSS_PREFIX . 'inc/inc_forms.php');
include ($CSS_PREFIX . 'inc/inc_head_html.php');

function email_check ($sEmail, $sSetting) {
	if ($sEmail == '')
		echo "<span class = 'sans-warn'>$sSetting is not set</span><br>";
	elseif (!eregi ("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]*)$", $sEmail))
		echo "<span class = 'sans-warn'>$sSetting: " . htmlentities ($sEmail) . " is not a valid e-mail address</span><br>\n";
	else
		echo "$sSetting: $sEmail<br>";
}

function string_check ($value, $setting, $default) {
	if ($value == $default)
		echo "<span class = 'sans-warn'>$setting is set to the default value ($default)</span><br>";
	else
		echo "$setting: $value<br>";
}
?>
<h1>Configuration Tests</h1>

<p>
This page performs some basic tests on the system configuration. It does not check absolutely everything, but is at least a quick check of the most important things. Anything that may require attention is in <span class = 'sans-warn'>bold red</span> text.
</p>

<p>
<?php
string_check (EVENT_CONTACT_NAME, 'EVENT_CONTACT_NAME', '');
email_check (EVENT_CONTACT_MAIL, 'EVENT_CONTACT_MAIL');
string_check (TECH_CONTACT_NAME, 'TECH_CONTACT_NAME', '');
email_check (TECH_CONTACT_MAIL, 'TECH_CONTACT_MAIL');
echo "</p>\n<p>\n";

string_check (TITLE, 'TITLE', '');
string_check (SYSTEM_NAME, 'SYSTEM_NAME', 'Bitsand');
if (RPG_NAME == 'LT')
	string_check (DEFAULT_FACTION, 'DEFAULT_FACTION', 'Lions');
echo "<p>\n";

if (MIN_PASS_LEN < 8)
	echo "<span class = 'sans-warn'>Minimum password length is short (" . MIN_PASS_LEN . ")</span><br>";
else
	echo "MIN_PASS_LEN: " . MIN_PASS_LEN . "<br>";
echo "<p>\n";

if (USE_PAY_PAL == False)
	echo "USE_PAY_PAL: False<br>";
else {
	echo "USE_PAY_PAL: True<br>";
	email_check (PAYPAL_EMAIL, 'PAYPAL_EMAIL');
	echo "<br><i>PayPal descriptions and costs:</i><p>\n";
	if (PAYPAL_AMOUNT_P1 != '')
		echo "PAYPAL_PLAYER_1: " . PAYPAL_PLAYER_1 . " (&pound;" . PAYPAL_AMOUNT_P1 . ")<br>\n";
	else
		echo "PAYPAL_PLAYER_1: " . PAYPAL_PLAYER_1 . " (<i>Will not appear as an option</i>)<br>\n";
	if (PAYPAL_AMOUNT_P2 != '')
		echo "PAYPAL_PLAYER_2: " . PAYPAL_PLAYER_2 . " (&pound;" . PAYPAL_AMOUNT_P2 . ")<br>\n";
	else
		echo "PAYPAL_PLAYER_2: " . PAYPAL_PLAYER_2 . " (<i>Will not appear as an option</i>)<br>\n";
	if (PAYPAL_AMOUNT_P3 != '')
		echo "PAYPAL_PLAYER_3: " . PAYPAL_PLAYER_3 . " (&pound;" . PAYPAL_AMOUNT_P3 . ")<br>\n";
	else
		echo "PAYPAL_PLAYER_3: " . PAYPAL_PLAYER_3 . " (<i>Will not appear as an option</i>)<br>\n";
	if (PAYPAL_AMOUNT_P4 != '')
		echo "PAYPAL_PLAYER_4: " . PAYPAL_PLAYER_4 . " (&pound;" . PAYPAL_AMOUNT_P4 . ")<br>\n";
	else
		echo "PAYPAL_PLAYER_4: " . PAYPAL_PLAYER_4 . " (<i>Will not appear as an option</i>)<br>\n";
	echo "<br>\n";
	if (ALLOW_MONSTER_BOOKINGS) {
		if (PAYPAL_AMOUNT_M1 != '')
			echo "PAYPAL_MONSTER_1: " . PAYPAL_MONSTER_1 . " (&pound;" . PAYPAL_AMOUNT_M1 . ")<br>\n";
		else
			echo "PAYPAL_MONSTER_1: " . PAYPAL_MONSTER_1 . " (<i>Will not appear as an option</i>)<br>\n";
		if (PAYPAL_AMOUNT_M2 != '')
			echo "PAYPAL_MONSTER_2: " . PAYPAL_MONSTER_2 . " (&pound;" . PAYPAL_AMOUNT_M2 . ")<br>\n";
		else
			echo "PAYPAL_MONSTER_2: " . PAYPAL_MONSTER_2 . " (<i>Will not appear as an option</i>)<br>\n";
		if (PAYPAL_AMOUNT_M3 != '')
			echo "PAYPAL_MONSTER_3: " . PAYPAL_MONSTER_3 . " (&pound;" . PAYPAL_AMOUNT_M3 . ")<br>\n";
		else
			echo "PAYPAL_MONSTER_3: " . PAYPAL_MONSTER_3 . " (<i>Will not appear as an option</i>)<br>\n";
		if (PAYPAL_AMOUNT_M4 != '')
			echo "PAYPAL_MONSTER_4: " . PAYPAL_MONSTER_4 . " (&pound;" . PAYPAL_AMOUNT_M4 . ")<br>\n";
		else
			echo "PAYPAL_MONSTER_4: " . PAYPAL_MONSTER_4 . " (<i>Will not appear as an option</i>)<br>\n";
		echo "<br>\n";
	}
	if (PAYPAL_AMOUNT_S1 != '')
		echo "PAYPAL_STAFF_1: " . PAYPAL_STAFF_1 . " (&pound;" . PAYPAL_AMOUNT_S1 . ")<br>\n";
	else
		echo "PAYPAL_STAFF_1: " . PAYPAL_STAFF_1 . " (<i>Will not appear as an option</i>)<br>\n";
	if (PAYPAL_AMOUNT_S2 != '')
		echo "PAYPAL_STAFF_2: " . PAYPAL_STAFF_2 . " (&pound;" . PAYPAL_AMOUNT_S2 . ")<br>\n";
	else
		echo "PAYPAL_STAFF_2: " . PAYPAL_STAFF_2 . " (<i>Will not appear as an option</i>)<br>\n";
	if (PAYPAL_AMOUNT_S3 != '')
		echo "PAYPAL_STAFF_3: " . PAYPAL_STAFF_3 . " (&pound;" . PAYPAL_AMOUNT_S3 . ")<br>\n";
	else
		echo "PAYPAL_STAFF_3: " . PAYPAL_STAFF_3 . " (<i>Will not appear as an option</i>)<br>\n";
	if (PAYPAL_AMOUNT_S4 != '')
		echo "PAYPAL_STAFF_4: " . PAYPAL_STAFF_4 . " (&pound;" . PAYPAL_AMOUNT_S4 . ")<br>\n";
	else
		echo "PAYPAL_STAFF_4: " . PAYPAL_STAFF_4 . " (<i>Will not appear as an option</i>)<br>\n";
}

include ('../inc/inc_foot.php');
?>
